home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
pwd
/
c
/
getpwuid
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
44 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/pwd/c/RCS/getpwuid,v $
* $Date: 1996/10/30 22:04:51 $
* $Revision: 1.1 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: getpwuid,v $
* Revision 1.1 1996/10/30 22:04:51 unixlib
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: getpwuid,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
/* pwd.c.getpwuid. Search for an entry with a matching user ID.
This is a POSIX.1 function written by Nick Burrett, 13 October 1996. */
#include <stddef.h>
#include <stdio.h>
#include <pwd.h>
#include <sys/types.h>
/* Search for an entry with a matching uid. */
struct passwd *
getpwuid (uid_t uid)
{
FILE *stream;
struct passwd *p;
stream = fopen ("/etc/passwd", "r");
if (stream == NULL)
return NULL;
while ((p = fgetpwent(stream)) != NULL)
if (p->pw_uid == uid)
break;
fclose(stream);
return p;
}